<template>
	<view class="home">
		<!-- 搜索区 -->
		<searchLink></searchLink>
		<!-- 轮播图 -->
		<swiper autoplay circular indicator-dots indicator-color="rgba(255,255,255,.3)" indicator-active-color="#fff" interval="3000">
			<swiper-item v-for="(item, index) in swiperdata" :key='index'>
				<image class='swiper-img' :src="item.image_src" mode=""></image>
			</swiper-item>
		</swiper>
		<!-- 导航 -->
		<view class="nav">
			<view class="nav-item" v-for='(item, index) in catitems' :key='index'>
				<image class='nav-img' :src="item.image_src" mode=""></image>
			</view>
		</view>
		<!-- 楼层 -->
		<view class='floor-item' v-for='(item,index) in floordata' :key='index'>
			<view class='floor-title'>
				<image :src="item.floor_title.image_src" alt="">
			</view>
			<view class="product-list">
				<view class='left'>
					<image :src="item.product_list[0].image_src" mode=""></image>
				</view>
				<view class="right">
					<block v-for='(subItem,subIndex) in item.product_list' :key='subIndex'>
							<image v-if='subIndex' :src="subItem.image_src" mode=""></image>
					</block>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import searchLink from '@/components/searchLink'
	export default {
		components: {
			searchLink
		},
		data() {
			return {
				swiperdata: [],
				catitems:[],
				floordata:[]
			}
		},
		methods:{
			async getSwiperData(){
				this.swiperdata = await this.$request({
					url: '/api/public/v1/home/swiperdata'
				})
			},
			async getCatitems(){
				this.catitems = await this.$request({
					url: '/api/public/v1/home/catitems'
				})
			},
			async getFloorData(){
				this.floordata = await this.$request({
					url: '/api/public/v1/home/floordata'
				})
			}
		},
		onLoad() {
			this.getSwiperData()
			this.getCatitems()
			this.getFloorData()
		}
	}
</script>

<style lang='less' scoped>
	.home{
		swiper{
			height: 340rpx;
			.swiper-img{
				height: 340rpx;
				width: 100%;
			}
		}
		.nav{
			height: 194rpx;
			display: flex;
			margin-top: 30rpx;
			justify-content: space-around;
			.nav-item{
				width: 128rpx;
				height: 140rpx;
				.nav-img{
					width: 100%;
					height: 100%;
				}
			}
		}
		.floor-item{
			width: 100%;
			margin-top: 20rpx;
			.floor-title {
				margin-bottom: 20rpx;
				background-color: #f4f4f4;
				width: 100%;
				height: 88rpx;
				>image {
					height: 80%;
					margin-top: 20rpx;
				}
			}
			.product-list{
				display: flex;
				padding: 0 17rpx;
				.left{
					width: 232rpx;
					height: 386rpx;
					> image{
						width: 100%;
					 height: 386rpx;
					}
				}
				.right{
					flex: 1;
					> image{
						width: 232rpx;
					  height: 188rpx;
						margin-left: 10rpx;
					}
				}
			}
		}
	}
</style>